package com.qiyue.service.impl;

import com.qiyue.mapper.MyFileMapper;
import com.qiyue.pojo.Myfile;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class MyFileServerImpl implements com.qiyue.service.MyFileServer {
    @Autowired
    private MyFileMapper myFileMapper;

    private static Logger logger = Logger.getLogger(MyFileServerImpl.class);

    @Override
    public Boolean upload(Myfile myfile) {
        logger.info("文件元数据："+myfile);
        return myFileMapper.insert(myfile) >= 1?true:false;
    }

    @Override
    public String findFileType(String uuid) {
        String fileType = myFileMapper.findFileType(uuid);
        logger.info("下载文件名称为："+uuid+"."+fileType);
        return uuid+"."+fileType;
    }

    @Override
    public Map<String,Object> findByUUID(String uuid) {
        Map<String,Object> myFileMap = myFileMapper.findByUUID(uuid);
        return myFileMap;
    }
}
